package com.situ.day11;

import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class GridLayoutDemo {

	public static void main(String[] args) {
		JFrame frame = new JFrame("GridLayoutDemo");
//		frame.setTitle("GridLayoutDemo");
		JPanel panel = new JPanel();
		frame.add(panel);
		panel.setLayout(new GridLayout(3, 3));
		JButton[] buttons = new JButton[9];
		for (int i = 0; i < buttons.length; i++) {
			buttons[i] = new JButton((i + 1) + "");
		}
		for (int i = 0; i < buttons.length; i++) {
			panel.add(buttons[i]);
		}

		frame.setSize(500, 400);
		frame.setLocation(500, 200);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	}

}
